+2004-03-05 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+ gboolean return values and GError arguments to
+ ::set_current_folder() and ::select_path().
+
+ * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+ Return a boolean value for success/failure.
+ (gtk_file_chooser_set_current_folder_uri): Likewise.
+ (gtk_file_chooser_select_filename): Likewise.
+ (gtk_file_chooser_select_uri): Likewise.
+ (gtk_file_chooser_set_filename): Likewise.
+ (gtk_file_chooser_set_uri): Likewise.
+ (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+ in a GError.
+ (_gtk_file_chooser_select_path): Likewise.
+
+ * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+ Likewise.
+ (delegate_select_path): Likewise.
+
+ * gtk/gtkfilechooserdefault.c
+ (gtk_file_chooser_default_select_path): Likewise.
+ (gtk_file_chooser_default_set_current_folder): Likewise.
+ (error_changing_folder_dialog): New helper function.
+ (change_folder_and_display_error): New helper function.
+ (switch_to_selected_folder): Use change_folder_and_display_error().
+ (tree_selection_changed): Likewise.
+ (shortcuts_activate_volume): Likewise.
+ (shortcuts_activate_item): Likewise.
+ (list_row_activated): Likewise.
+ (path_bar_clicked): Likewise.
+ (update_from_entry): Likewise.
+ (up_folder_handler): Likewise.
+ (home_folder_handler): Get the home path from the shortcuts model,
+ and use change_folder_and_display_error().
+
+ * tests/testfilechooser.c (set_current_folder): New helper
+ function; pops up a simple error dialog if necessary.
+ (set_filename): Likewise.
+ (set_folder_nonexistent_cb): Use set_current_folder().
+ (set_folder_existing_nonexistent_cb): Likewise.
+ (set_filename_nonexistent_cb): Use set_filename().
+ (set_filename_existing_nonexistent_cb): Likewise.
+
Fri Mar 5 11:17:35 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy):
+2004-03-05 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+ gboolean return values and GError arguments to
+ ::set_current_folder() and ::select_path().
+
+ * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+ Return a boolean value for success/failure.
+ (gtk_file_chooser_set_current_folder_uri): Likewise.
+ (gtk_file_chooser_select_filename): Likewise.
+ (gtk_file_chooser_select_uri): Likewise.
+ (gtk_file_chooser_set_filename): Likewise.
+ (gtk_file_chooser_set_uri): Likewise.
+ (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+ in a GError.
+ (_gtk_file_chooser_select_path): Likewise.
+
+ * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+ Likewise.
+ (delegate_select_path): Likewise.
+
+ * gtk/gtkfilechooserdefault.c
+ (gtk_file_chooser_default_select_path): Likewise.
+ (gtk_file_chooser_default_set_current_folder): Likewise.
+ (error_changing_folder_dialog): New helper function.
+ (change_folder_and_display_error): New helper function.
+ (switch_to_selected_folder): Use change_folder_and_display_error().
+ (tree_selection_changed): Likewise.
+ (shortcuts_activate_volume): Likewise.
+ (shortcuts_activate_item): Likewise.
+ (list_row_activated): Likewise.
+ (path_bar_clicked): Likewise.
+ (update_from_entry): Likewise.
+ (up_folder_handler): Likewise.
+ (home_folder_handler): Get the home path from the shortcuts model,
+ and use change_folder_and_display_error().
+
+ * tests/testfilechooser.c (set_current_folder): New helper
+ function; pops up a simple error dialog if necessary.
+ (set_filename): Likewise.
+ (set_folder_nonexistent_cb): Use set_current_folder().
+ (set_folder_existing_nonexistent_cb): Likewise.
+ (set_filename_nonexistent_cb): Use set_filename().
+ (set_filename_existing_nonexistent_cb): Likewise.
+
Fri Mar 5 11:17:35 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy):
+2004-03-05 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+ gboolean return values and GError arguments to
+ ::set_current_folder() and ::select_path().
+
+ * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+ Return a boolean value for success/failure.
+ (gtk_file_chooser_set_current_folder_uri): Likewise.
+ (gtk_file_chooser_select_filename): Likewise.
+ (gtk_file_chooser_select_uri): Likewise.
+ (gtk_file_chooser_set_filename): Likewise.
+ (gtk_file_chooser_set_uri): Likewise.
+ (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+ in a GError.
+ (_gtk_file_chooser_select_path): Likewise.
+
+ * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+ Likewise.
+ (delegate_select_path): Likewise.
+
+ * gtk/gtkfilechooserdefault.c
+ (gtk_file_chooser_default_select_path): Likewise.
+ (gtk_file_chooser_default_set_current_folder): Likewise.
+ (error_changing_folder_dialog): New helper function.
+ (change_folder_and_display_error): New helper function.
+ (switch_to_selected_folder): Use change_folder_and_display_error().
+ (tree_selection_changed): Likewise.
+ (shortcuts_activate_volume): Likewise.
+ (shortcuts_activate_item): Likewise.
+ (list_row_activated): Likewise.
+ (path_bar_clicked): Likewise.
+ (update_from_entry): Likewise.
+ (up_folder_handler): Likewise.
+ (home_folder_handler): Get the home path from the shortcuts model,
+ and use change_folder_and_display_error().
+
+ * tests/testfilechooser.c (set_current_folder): New helper
+ function; pops up a simple error dialog if necessary.
+ (set_filename): Likewise.
+ (set_folder_nonexistent_cb): Use set_current_folder().
+ (set_folder_existing_nonexistent_cb): Likewise.
+ (set_filename_nonexistent_cb): Use set_filename().
+ (set_filename_existing_nonexistent_cb): Likewise.
+
Fri Mar 5 11:17:35 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy):
+2004-03-05 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+ gboolean return values and GError arguments to
+ ::set_current_folder() and ::select_path().
+
+ * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+ Return a boolean value for success/failure.
+ (gtk_file_chooser_set_current_folder_uri): Likewise.
+ (gtk_file_chooser_select_filename): Likewise.
+ (gtk_file_chooser_select_uri): Likewise.
+ (gtk_file_chooser_set_filename): Likewise.
+ (gtk_file_chooser_set_uri): Likewise.
+ (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+ in a GError.
+ (_gtk_file_chooser_select_path): Likewise.
+
+ * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+ Likewise.
+ (delegate_select_path): Likewise.
+
+ * gtk/gtkfilechooserdefault.c
+ (gtk_file_chooser_default_select_path): Likewise.
+ (gtk_file_chooser_default_set_current_folder): Likewise.
+ (error_changing_folder_dialog): New helper function.
+ (change_folder_and_display_error): New helper function.
+ (switch_to_selected_folder): Use change_folder_and_display_error().
+ (tree_selection_changed): Likewise.
+ (shortcuts_activate_volume): Likewise.
+ (shortcuts_activate_item): Likewise.
+ (list_row_activated): Likewise.
+ (path_bar_clicked): Likewise.
+ (update_from_entry): Likewise.
+ (up_folder_handler): Likewise.
+ (home_folder_handler): Get the home path from the shortcuts model,
+ and use change_folder_and_display_error().
+
+ * tests/testfilechooser.c (set_current_folder): New helper
+ function; pops up a simple error dialog if necessary.
+ (set_filename): Likewise.
+ (set_folder_nonexistent_cb): Use set_current_folder().
+ (set_folder_existing_nonexistent_cb): Likewise.
+ (set_filename_nonexistent_cb): Use set_filename().
+ (set_filename_existing_nonexistent_cb): Likewise.
+
Fri Mar 5 11:17:35 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy):
+2004-03-05 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+ gboolean return values and GError arguments to
+ ::set_current_folder() and ::select_path().
+
+ * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+ Return a boolean value for success/failure.
+ (gtk_file_chooser_set_current_folder_uri): Likewise.
+ (gtk_file_chooser_select_filename): Likewise.
+ (gtk_file_chooser_select_uri): Likewise.
+ (gtk_file_chooser_set_filename): Likewise.
+ (gtk_file_chooser_set_uri): Likewise.
+ (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+ in a GError.
+ (_gtk_file_chooser_select_path): Likewise.
+
+ * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+ Likewise.
+ (delegate_select_path): Likewise.
+
+ * gtk/gtkfilechooserdefault.c
+ (gtk_file_chooser_default_select_path): Likewise.
+ (gtk_file_chooser_default_set_current_folder): Likewise.
+ (error_changing_folder_dialog): New helper function.
+ (change_folder_and_display_error): New helper function.
+ (switch_to_selected_folder): Use change_folder_and_display_error().
+ (tree_selection_changed): Likewise.
+ (shortcuts_activate_volume): Likewise.
+ (shortcuts_activate_item): Likewise.
+ (list_row_activated): Likewise.
+ (path_bar_clicked): Likewise.
+ (update_from_entry): Likewise.
+ (up_folder_handler): Likewise.
+ (home_folder_handler): Get the home path from the shortcuts model,
+ and use change_folder_and_display_error().
+
+ * tests/testfilechooser.c (set_current_folder): New helper
+ function; pops up a simple error dialog if necessary.
+ (set_filename): Likewise.
+ (set_folder_nonexistent_cb): Use set_current_folder().
+ (set_folder_existing_nonexistent_cb): Likewise.
+ (set_filename_nonexistent_cb): Use set_filename().
+ (set_filename_existing_nonexistent_cb): Likewise.
+
Fri Mar 5 11:17:35 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy):
* for the directory change. To pre-enter a filename for the user, as in
* a save-as dialog, use gtk_file_chooser_set_current_name()
*
+ * Return value: %TRUE if both the folder could be changed and the file was
+ * selected successfully, %FALSE otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
gtk_file_chooser_set_filename (GtkFileChooser *chooser,
const gchar *filename)
{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
gtk_file_chooser_unselect_all (chooser);
- gtk_file_chooser_select_filename (chooser, filename);
+ return gtk_file_chooser_select_filename (chooser, filename);
}
/**
* folder of @chooser, then the current folder of @chooser will
* be changed to the folder containing @filename.
*
+ * Return value: %TRUE if both the folder could be changed and the file was
+ * selected successfully, %FALSE otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
gtk_file_chooser_select_filename (GtkFileChooser *chooser,
const gchar *filename)
{
GtkFileSystem *file_system;
GtkFilePath *path;
+ gboolean result;
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
- g_return_if_fail (filename != NULL);
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_filename_to_path (file_system, filename);
if (path)
{
- _gtk_file_chooser_select_path (chooser, path);
+ result = _gtk_file_chooser_select_path (chooser, path, NULL);
gtk_file_path_free (path);
}
+ else
+ result = FALSE;
+
+ return result;
}
/**
* The user will be shown the full contents of the current folder,
* plus user interface elements for navigating to other folders.
*
+ * Return value: %TRUE if the folder could be changed successfully, %FALSE
+ * otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
const gchar *filename)
{
GtkFileSystem *file_system;
GtkFilePath *path;
+ gboolean result;
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
- g_return_if_fail (filename != NULL);
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_filename_to_path (file_system, filename);
if (path)
{
- _gtk_file_chooser_set_current_folder_path (chooser, path);
+ result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
gtk_file_path_free (path);
}
+ else
+ result = FALSE;
+
+ return result;
}
/**
* for the directory change. To pre-enter a filename for the user, as in
* a save-as dialog, use gtk_file_chooser_set_current_name()
*
+ * Return value: %TRUE if both the folder could be changed and the URI was
+ * selected successfully, %FALSE otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
gtk_file_chooser_set_uri (GtkFileChooser *chooser,
const char *uri)
{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
gtk_file_chooser_unselect_all (chooser);
- gtk_file_chooser_select_uri (chooser, uri);
+ return gtk_file_chooser_select_uri (chooser, uri);
}
/**
* file in the current folder of @chooser, then the current folder of
* @chooser will be changed to the folder containing @filename.
*
+ * Return value: %TRUE if both the folder could be changed and the URI was
+ * selected successfully, %FALSE otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
gtk_file_chooser_select_uri (GtkFileChooser *chooser,
const char *uri)
{
GtkFileSystem *file_system;
GtkFilePath *path;
+ gboolean result;
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
- g_return_if_fail (uri != NULL);
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_uri_to_path (file_system, uri);
if (path)
{
- _gtk_file_chooser_select_path (chooser, path);
+ result = _gtk_file_chooser_select_path (chooser, path, NULL);
gtk_file_path_free (path);
}
+ else
+ result = FALSE;
+
+ return result;
}
/**
* The user will be shown the full contents of the current folder,
* plus user interface elements for navigating to other folders.
*
+ * Return value: %TRUE if the folder could be changed successfully, %FALSE
+ * otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
const gchar *uri)
{
GtkFileSystem *file_system;
GtkFilePath *path;
+ gboolean result;
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
- g_return_if_fail (uri != NULL);
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_uri_to_path (file_system, uri);
if (path)
{
- _gtk_file_chooser_set_current_folder_path (chooser, path);
+ result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
gtk_file_path_free (path);
}
+ else
+ result = FALSE;
+
+ return result;
}
/**
* _gtk_file_chooser_set_current_folder_path:
* @chooser: a #GtkFileChooser
* @path: the #GtkFilePath for the new folder
+ * @error: location to store error, or %NULL.
*
* Sets the current folder for @chooser from a #GtkFilePath.
* Internal function, see gtk_file_chooser_set_current_folder_uri().
*
+ * Return value: %TRUE if the folder could be changed successfully, %FALSE
+ * otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
_gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
- const GtkFilePath *path)
+ const GtkFilePath *path,
+ GError **error)
{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
- g_return_if_fail (path != NULL);
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path);
+ return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
}
/**
* _gtk_file_chooser_select_path:
* @chooser: a #GtkFileChooser
* @path: the path to select
+ * @error: location to store error, or %NULL
*
* Selects the file referred to by @path. An internal function. See
* _gtk_file_chooser_select_uri().
*
+ * Return value: %TRUE if both the folder could be changed and the path was
+ * selected successfully, %FALSE otherwise.
+ *
* Since: 2.4
**/
-void
+gboolean
_gtk_file_chooser_select_path (GtkFileChooser *chooser,
- const GtkFilePath *path)
+ const GtkFilePath *path,
+ GError **error)
{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path);
+ return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
}
/**
gboolean select_multiple);
gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
+/* Suggested name for the Save-type actions
+ */
+void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
+ const gchar *name);
+
/* Filename manipulation
*/
-void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
- const gchar *name);
-gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser);
-void gtk_file_chooser_set_filename (GtkFileChooser *chooser,
- const char *filename);
-void gtk_file_chooser_select_filename (GtkFileChooser *chooser,
- const char *filename);
-void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
- const char *filename);
-void gtk_file_chooser_select_all (GtkFileChooser *chooser);
-void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
-GSList *gtk_file_chooser_get_filenames (GtkFileChooser *chooser);
-void gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
- const gchar *filename);
-gchar *gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
+gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser,
+ const char *filename);
+gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser,
+ const char *filename);
+void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
+ const char *filename);
+void gtk_file_chooser_select_all (GtkFileChooser *chooser);
+void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
+GSList * gtk_file_chooser_get_filenames (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
+ const gchar *filename);
+gchar * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
/* URI manipulation
*/
-gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser);
-void gtk_file_chooser_set_uri (GtkFileChooser *chooser,
- const char *uri);
-void gtk_file_chooser_select_uri (GtkFileChooser *chooser,
- const char *uri);
-void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
- const char *uri);
-GSList *gtk_file_chooser_get_uris (GtkFileChooser *chooser);
-
-void gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
- const gchar *uri);
-gchar *gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
+gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser,
+ const char *uri);
+gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser,
+ const char *uri);
+void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
+ const char *uri);
+GSList * gtk_file_chooser_get_uris (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
+ const gchar *uri);
+gchar * gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
/* Preview widget
*/
static void gtk_file_chooser_default_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen);
-static void gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
- const GtkFilePath *path);
+static gboolean gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
static GtkFilePath * gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser);
static void gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
const gchar *name);
-static void gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
- const GtkFilePath *path);
+static gboolean gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
static void gtk_file_chooser_default_unselect_path (GtkFileChooser *chooser,
const GtkFilePath *path);
static void gtk_file_chooser_default_select_all (GtkFileChooser *chooser);
g_error_free (error);
}
+/* Shows an error dialog when we cannot switch to a folder */
+static void
+error_changing_folder_dialog (GtkFileChooserDefault *impl,
+ const GtkFilePath *path,
+ GError *error)
+{
+ error_dialog (impl,
+ _("Could not change the current folder to %s:\n%s"),
+ path,
+ error);
+}
+
+/* Changes folders, displaying an error dialog if this fails */
+static gboolean
+change_folder_and_display_error (GtkFileChooserDefault *impl,
+ const GtkFilePath *path)
+{
+ GError *error;
+ gboolean result;
+
+ error = NULL;
+ result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path, &error);
+
+ if (!result)
+ error_changing_folder_dialog (impl, path, error);
+
+ return result;
+}
+
static void
update_preview_widget_visibility (GtkFileChooserDefault *impl)
{
base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
else
base_path = NULL;
-
+
if (base_path &&
strcmp (gtk_file_path_get_string (base_path), gtk_file_path_get_string (impl->current_folder)) == 0)
{
gtk_file_info_get_display_name (info));
}
-static void
+static gboolean
gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
- const GtkFilePath *path)
+ const GtkFilePath *path,
+ GError **error)
{
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
- GError *error;
+ GError *err;
- error = NULL;
- if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, &error))
+ err = NULL;
+ if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, &err))
{
- error_dialog (impl,
- _("Could not set current folder: %s"),
- path, error);
- return;
+ g_propagate_error (error, err);
+ return FALSE;
}
if (impl->current_folder != path)
bookmarks_check_add_sensitivity (impl);
g_signal_emit_by_name (impl, "selection-changed", 0);
+
+ return TRUE;
}
static GtkFilePath *
gtk_tree_path_free (sorted_path);
}
-static void
+static gboolean
gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
- const GtkFilePath *path)
+ const GtkFilePath *path,
+ GError **error)
{
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
GtkFilePath *parent_path;
- GError *error;
+ GError *err;
- error = NULL;
- if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, &error))
+ err = NULL;
+ if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, &err))
{
- error_getting_info_dialog (impl, path, error);
- return;
+ g_propagate_error (error, err);
+ return FALSE;
}
if (!parent_path)
- {
- _gtk_file_chooser_set_current_folder_path (chooser, path);
- }
+ return _gtk_file_chooser_set_current_folder_path (chooser, path, error);
else
{
- _gtk_file_chooser_set_current_folder_path (chooser, parent_path);
+ gboolean result;
+
+ result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error);
gtk_file_path_free (parent_path);
_gtk_file_system_model_path_do (impl->browse_files_model, path,
select_func, impl);
+
+ return result;
}
+
+ g_assert_not_reached ();
}
static void
g_assert (closure.path && closure.num_selected == 1);
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), closure.path);
+ change_folder_and_display_error (impl, closure.path);
}
/* Implementation for GtkFileChooserEmbed::should_respond() */
gtk_tree_path_free (path);
if (!impl->changing_folder)
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+ change_folder_and_display_error (impl, file_path);
}
/* Activates a volume by mounting it if necessary and then switching to its
}
path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path);
+ change_folder_and_display_error (impl, path);
gtk_file_path_free (path);
}
}
else
{
- GtkFilePath *file_path;
+ const GtkFilePath *file_path;
file_path = data;
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+ change_folder_and_display_error (impl, file_path);
}
}
const GtkFilePath *file_path;
file_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+ change_folder_and_display_error (impl, file_path);
return;
}
GtkFilePath *file_path,
GtkFileChooserDefault *impl)
{
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+ change_folder_and_display_error (impl, file_path);
}
static const GtkFileInfo *
if (file_part[0] == '\0')
{
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), folder_path);
+ change_folder_and_display_error (impl, folder_path);
return;
}
else
}
if (gtk_file_info_get_is_folder (info))
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), subfolder_path);
+ change_folder_and_display_error (impl, subfolder_path);
else
- _gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path);
+ {
+ GError *error;
+
+ error = NULL;
+ if (!_gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path, &error))
+ error_dialog (impl,
+ _("Could not select %s:\n%s"),
+ subfolder_path,
+ error);
+ }
g_object_unref (folder);
gtk_file_path_free (subfolder_path);
{
if (parent_path) /* If we were on a root, parent_path will be NULL */
{
- _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), parent_path);
+ change_folder_and_display_error (impl, parent_path);
gtk_file_path_free (parent_path);
}
}
static void
home_folder_handler (GtkFileChooserDefault *impl)
{
- const char *home;
+ int pos;
+ GtkTreeIter iter;
+ GtkFilePath *path;
- /* Should we pull this information from impl->has_home and the shortcuts data
- * instead? Sounds like a bit of overkill...
- */
+ if (!impl->has_home)
+ return; /* Should we put up an error dialog? */
- home = g_get_home_dir ();
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), home);
+ pos = shortcuts_get_index (impl, SHORTCUTS_HOME);
+ if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
+ g_assert_not_reached ();
+
+ gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &path, -1);
+ g_assert (path != NULL);
+
+ change_folder_and_display_error (impl, path);
}
/* Methods
*/
- void (*set_current_folder) (GtkFileChooser *chooser,
- const GtkFilePath *path);
+ gboolean (*set_current_folder) (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
GtkFilePath * (*get_current_folder) (GtkFileChooser *chooser);
void (*set_current_name) (GtkFileChooser *chooser,
const gchar *name);
- void (*select_path) (GtkFileChooser *chooser,
- const GtkFilePath *path);
+ gboolean (*select_path) (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
void (*unselect_path) (GtkFileChooser *chooser,
const GtkFilePath *path);
void (*select_all) (GtkFileChooser *chooser);
};
GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser);
-void _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
- const GtkFilePath *path);
+gboolean _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
GtkFilePath * _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser);
-void _gtk_file_chooser_select_path (GtkFileChooser *chooser,
- const GtkFilePath *path);
+gboolean _gtk_file_chooser_select_path (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
void _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
const GtkFilePath *path);
GSList * _gtk_file_chooser_get_paths (GtkFileChooser *chooser);
#include "gtkfilesystem.h"
#include "gtktypebuiltins.h"
-static void delegate_set_current_folder (GtkFileChooser *chooser,
- const GtkFilePath *path);
+static gboolean delegate_set_current_folder (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
static GtkFilePath * delegate_get_current_folder (GtkFileChooser *chooser);
static void delegate_set_current_name (GtkFileChooser *chooser,
const gchar *name);
-static void delegate_select_path (GtkFileChooser *chooser,
- const GtkFilePath *path);
+static gboolean delegate_select_path (GtkFileChooser *chooser,
+ const GtkFilePath *path,
+ GError **error);
static void delegate_unselect_path (GtkFileChooser *chooser,
const GtkFilePath *path);
static void delegate_select_all (GtkFileChooser *chooser);
/**
* _gtk_file_chooser_install_properties:
* @klass: the class structure for a type deriving from #GObject
- *
+ *
* Installs the necessary properties for a class implementing
* #GtkFileChooser. A #GtkParamSpecOverride property is installed
* for each property, using the values from the #GtkFileChooserProp
/**
* _gtk_file_chooser_delegate_iface_init:
* @iface: a #GtkFileChoserIface structure
- *
+ *
* An interface-initialization function for use in cases where
* an object is simply delegating the methods, signals of
* the #GtkFileChooser interface to another object.
{
g_return_if_fail (GTK_IS_FILE_CHOOSER (receiver));
g_return_if_fail (GTK_IS_FILE_CHOOSER (delegate));
-
+
g_object_set_data (G_OBJECT (receiver), "gtk-file-chooser-delegate", delegate);
g_signal_connect (delegate, "notify",
return g_object_get_data (G_OBJECT (receiver), "gtk-file-chooser-delegate");
}
-static void
+static gboolean
delegate_select_path (GtkFileChooser *chooser,
- const GtkFilePath *path)
+ const GtkFilePath *path,
+ GError **error)
{
- _gtk_file_chooser_select_path (get_delegate (chooser), path);
+ return _gtk_file_chooser_select_path (get_delegate (chooser), path, error);
}
static void
return gtk_file_chooser_list_shortcut_folders (get_delegate (chooser));
}
-static void
+static gboolean
delegate_set_current_folder (GtkFileChooser *chooser,
- const GtkFilePath *path)
+ const GtkFilePath *path,
+ GError **error)
{
- _gtk_file_chooser_set_current_folder_path (get_delegate (chooser), path);
+ return _gtk_file_chooser_set_current_folder_path (get_delegate (chooser), path, error);
}
static GtkFilePath *